using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using GeoFramework.Gps.Nmea;

namespace GeoFramework.Examples
{
    public partial class ConnectingAndDisconnectingForm : Form
    {
        public ConnectingAndDisconnectingForm()
        {
            InitializeComponent();
        }

        private void GpsDevice_SentenceReceived(object sender, NmeaSentenceEventArgs e)
        {
            // Put the sentence in the list box
            RawDataListBox.Items.Add(e.Sentence.ToString());
            RawDataListBox.SelectedIndex = RawDataListBox.Items.Count - 1;
            // Keep the list items from growing too large
            if (RawDataListBox.Items.Count > 100)
                RawDataListBox.Items.RemoveAt(0);
        }

        private void StartButton_Click(object sender, System.EventArgs e)
        {
            // Begin GPS communications
            GpsDevice.Start();

            // Enable the stop button, disable the start button
            StopButton.Enabled = true;
            StartButton.Enabled = false;
        }

        private void StopButton_Click(object sender, System.EventArgs e)
        {
            // Stop GPS communications
            GpsDevice.Stop();

            // Re-enable the Start button
            StartButton.Enabled = true;
            StopButton.Enabled = false;
        }
    }
}